<?php

	class xl_tintuc extends database

	{

		function Load_Tin_Tuc_Moi($ma)

		{

			$sql = "Select * from tintuc where maloaitrang = '7' and matintuc <> $ma  

					ORDER BY (ngaydang) DESC LIMIT 0 , 5";

			$this->setQuery($sql);

			$arr = $this->loadAllRow();

			$this->disconnect(); 

			return $arr;

		}

		function Load_Kien_Thuc_Moi($ma)

		{

			$sql = "Select * from tintuc where maloaitrang = '6' and matintuc <> $ma  

					ORDER BY (ngaydang) DESC LIMIT 0 , 5";

			$this->setQuery($sql);

			$arr = $this->loadAllRow();

			$this->disconnect(); 

			return $arr;

		}
		function Load_Top5()

		{

			$sql = "Select * from tintuc ORDER BY (ngaydang) DESC LIMIT 0 , 5";

			$this->setQuery($sql);

			$arr = $this->loadAllRow();

			$this->disconnect(); 

			return $arr;

		}

		function Load_Top2_Tin_Tuc()

		{

			$sql = "Select * from tintuc where maloaitrang = '7' ORDER BY (ngaydang) DESC LIMIT 0 , 2";

			$this->setQuery($sql);

			$arr = $this->loadAllRow();

			$this->disconnect(); 

			return $arr;

		}

		//Phuong - ADD - END- 21/5/2012		

		//Phuong - ADD - START - 21/2/2012

		function Load_KienThucTheoMa($matintuc)

		{

			$sql = "Select * from tintuc where matintuc = '".$matintuc."' and maloaitrang='6'";

			$this->setQuery($sql);

			$arr = $this->loadOneRow();

			$this->disconnect(); 

			return $arr;

		}

		

		function Load_TinTucTheoMa($matintuc)

		{

			$sql = "Select * from tintuc where matintuc = '".$matintuc."' and maloaitrang='7'";

			$this->setQuery($sql);

			$arr = $this->loadOneRow();

			$this->disconnect(); 

			return $arr;

		}

		//Phuong - ADD - END - 21/2/2012

		

		function Load_KienThuc($start, $display)
		{
			$sql = "Select * from tintuc where maloaitrang = '6' ORDER BY (ngaydang) DESC LIMIT $start, $display";
			$this->setQuery($sql);
			$arr = $this->loadAllRow();
			$this->disconnect(); 
			return $arr;
		}
		
		function DemTrangKienThuc()

		{
			$sql = "Select COUNT(matintuc) as tong from tintuc where maloaitrang = '6'";
			$this->setQuery($sql);
			$arr = $this->loadOneRow();
			$this->disconnect(); 
			return $arr;
		}

		

	function Load_TinTuc($start, $display)

		{
			$sql = "Select * from tintuc where maloaitrang = '7' ORDER BY (ngaydang) DESC LIMIT $start, $display";
			$this->setQuery($sql);
			$arr = $this->loadAllRow();
			$this->disconnect(); 
			return $arr;
		}
		
		function DemTrangTinTuc()

		{
			$sql = "Select COUNT(matintuc) as tong from tintuc where maloaitrang = '7'";
			$this->setQuery($sql);
			$arr = $this->loadOneRow();
			$this->disconnect(); 
			return $arr;
		}

		

		//Toan - ADD START- 23/2/2012

		function Load_Top5TinTuc()

		{

			$sql = "Select * from tintuc where maloaitrang = '7' ORDER BY (ngaydang) DESC LIMIT 0 , 5";

			$this->setQuery($sql);

			$arr = $this->loadAllRow();

			$this->disconnect(); 

			return $arr;

		}


		function Load_Top7KienThuc()

		{

			$sql = "Select * from tintuc where maloaitrang = '6' ORDER BY (ngaydang) DESC LIMIT 0 , 7";

			$this->setQuery($sql);

			$arr = $this->loadAllRow();

			$this->disconnect(); 

			return $arr;

		}

		//Toan - ADD END - 23/2/2012





		function capnhat($matt,$txtTieuDe,$noidungthugon,$noidungdaydu,$tukhoa,$hinhanh,$manguoi,$mota)

		{

			$sql = "UPDATE tintuc set tieude ='".$txtTieuDe."', noidungthugon ='".$noidungthugon."',noidungdaydu='".$noidungdaydu."',hinhanh='".$hinhanh."',tags='".$tukhoa."',manguoidung='".$manguoi."',mota='".$mota."' where matintuc =".$matt;

			$this->setQuery($sql);

			return $this->query(); 

			

		}

		function capnhat1($matt,$txtTieuDe,$noidungthugon,$noidungdaydu,$tukhoa,$manguoi,$mota)

		{

			$sql = "UPDATE tintuc set tieude ='".$txtTieuDe."', noidungthugon ='".$noidungthugon."',noidungdaydu='".$noidungdaydu."',tags='".$tukhoa."',manguoidung='".$manguoi."',mota='".$mota."' where matintuc =".$matt;

			$this->setQuery($sql);

			return $this->query(); 

			

		}

		

		function them_tintuc($txtTieuDe,$noidungthugon,$noidungdaydu,$tukhoa,$hinhanh,$ngaydang,$manguoi,$mota)

		{

			$sql = "INSERT INTO tintuc (maloaitrang,tieude,noidungthugon,noidungdaydu,tags,hinhanh,ngaydang,manguoidung,mota) VALUES ('7','".$txtTieuDe."','".$noidungthugon."','".$noidungdaydu."','".$tukhoa."','".$hinhanh."','".$ngaydang."','".$manguoi."','".$mota."')";

			$this->setQuery($sql);

			return $this->query();

			//return $sql;

			

		}

		

		function them_tintuc1($txtTieuDe,$noidungthugon,$noidungdaydu,$tukhoa,$ngaydang,$manguoi,$mota)

		{

			$sql = "INSERT INTO tintuc (maloaitrang,tieude,noidungthugon,noidungdaydu,tags,ngaydang,manguoidung,mota) VALUES ('7','".$txtTieuDe."','".$noidungthugon."','".$noidungdaydu."','".$tukhoa."','".$ngaydang."','".$manguoi."','".$mota."')";

			$this->setQuery($sql);

			return $this->query();

			//return $sql;

			

		}

		

		//Phuong - ADD - START - 02/03/2012

		function them_kienthuc($txtTieuDe,$noidungthugon,$noidungdaydu,$tukhoa,$hinhanh,$ngaydang,$manguoi,$mota)

		{

			$sql = "INSERT INTO tintuc (maloaitrang,tieude,noidungthugon,noidungdaydu,tags,hinhanh,ngaydang,manguoidung,mota) VALUES ('6','".$txtTieuDe."','".$noidungthugon."','".$noidungdaydu."','".$tukhoa."','".$hinhanh."','".$ngaydang."','".$manguoi."','".$mota."')";

			$this->setQuery($sql);

			return $this->query();

			//return $sql;

			

		}

		

		function them_kienthuc1($txtTieuDe,$noidungthugon,$noidungdaydu,$tukhoa,$ngaydang,$manguoi,$mota)

		{

			$sql = "INSERT INTO tintuc (maloaitrang,tieude,noidungthugon,noidungdaydu,tags,ngaydang,manguoidung,mota) VALUES ('6','".$txtTieuDe."','".$noidungthugon."','".$noidungdaydu."','".$tukhoa."','".$ngaydang."','".$manguoi."','".$mota."')";

			$this->setQuery($sql);

			return $this->query();

			//return $sql;

			

		}

		//Phuong - ADD - END - 02/03/2012

		

		function xoa_tin_tuc($id)

		{

			$sql ="delete from tintuc where matintuc = '".$id."'";

			$this->setQuery($sql);

			return $this->query();

		}
		function Load_All_TinTuc()
		{
			$sql = "Select * from tintuc where maloaitrang = '7' ORDER BY (ngaydang) DESC ";
			$this->setQuery($sql);
			$arr = $this->loadAllRow();
			$this->disconnect(); 
			return $arr;
		}
		
		function Load_All_TinTuc_Limit($start, $display)
		{
			$sql = "Select * from tintuc where maloaitrang = '7' ORDER BY (ngaydang) DESC LIMIT $start, $display";
			$this->setQuery($sql);
			$arr = $this->loadAllRow();
			$this->disconnect(); 
			return $arr;
		}
		
		function Load_All_KienThuc()
		{
			$sql = "Select * from tintuc where maloaitrang = '6' ORDER BY (ngaydang) DESC ";
			$this->setQuery($sql);
			$arr = $this->loadAllRow();
			$this->disconnect(); 
			return $arr;
		}
		
		function Load_All_KienThuc_Limit($start, $display)
		{
			$sql = "Select * from tintuc where maloaitrang = '6' ORDER BY (ngaydang) DESC LIMIT $start, $display";
			$this->setQuery($sql);
			$arr = $this->loadAllRow();
			$this->disconnect(); 
			return $arr;
		}

	}

?>